﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using cms.libs;

namespace CMS.API
{
    /// <summary>
    /// Summary description for Handler1
    /// </summary>
    public class Handler1 : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            switch (context.Request["p"])
            {
                
                case "doanthu":
                    GetDoanhThu(context);
                    break;
            }
        }

        private void GetDoanhThu(HttpContext context)
        {
            

            try
            {
                DateTime fromD = DateTime.Now.AddDays(-7);
                DateTime toD=DateTime.Now;
                
                var lstDt = new DBIncome().GetListDataTable(fromD, toD);
                
                

                
                context.Response.ContentType = "application/json";
                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(lstDt));
            }
            catch (Exception ex)
            {
               
                
                context.Response.ContentType = "application/json";
                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(-1));
            }

        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}